package top.ly61.core.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import top.ly61.common.exception.Assert;
import top.ly61.common.result.ResponseEnum;
import top.ly61.core.pojo.entity.Student;
import top.ly61.core.mapper.StudentMapper;
import top.ly61.core.service.StudentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author suk_mit
 * @since 2022-01-27
 */
@Service
public class StudentServiceImpl extends ServiceImpl<StudentMapper, Student> implements StudentService {

    @Autowired
    StudentMapper studentMapper;

    @Override
    public List<Student> getAllStudents() {
        List<Student> studentList = studentMapper.getAllStudents();
        Assert.isNull(studentList, ResponseEnum.WEIXIN_FETCH_USERINFO_ERROR);
        return studentList;
    }

    @Override
    public Student getStudengById(String id) {
        Student student = studentMapper.getStudentById(id);
        Assert.isNull(student,ResponseEnum.WEIXIN_FETCH_USERINFO_ERROR);
        return student;
    }
}
